package com.irdstudio.apicenter.console.controller.scan;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.irdstudio.apicenter.console.controller.MacmsBaseAction;
import com.irdstudio.apicenter.console.util.MacmsPathUtil;
/**
 * 应用扫描主类
 * @author gaungming.li
 * @version 1.0
 * @date 2016-02-19
 */
@Controller
@RequestMapping(value = "/scan")
public class ScanMainAction extends MacmsBaseAction {
	
	/**
	 * 应用扫描控制台首页
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "scanIndex")
	public ModelAndView scanIndex(HttpServletRequest request) throws Exception {
		String appid = request.getParameter("appid");
		String appName = java.net.URLDecoder.decode(request
				.getParameter("appName"), "UTF-8");
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("appid", appid);
		modelAndView.addObject("appName", appName);
		modelAndView.setViewName("scan/scanIndex");
		return modelAndView;
	}
	
	@RequestMapping(value = "scanAppCode")
	public ModelAndView scanAppCode(HttpServletRequest request) throws Exception {
		String appid = request.getParameter("appid");
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.addObject("appid", appid);
		request.setAttribute("appprj", MacmsPathUtil.getMacmsAppPrjPath(appid));
		modelAndView.setViewName("scan/scanAppCode");
		return modelAndView;
	}	

}
